package com.tcenter.services.impl;

import com.tcenter.dao.entities.*;
import com.tcenter.dao.entities.Lecturer;
import com.tcenter.dao.providers.LecturerDAO;
import com.tcenter.services.LecturerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * User: Andrey Pautov
 * Date: 28.05.13
 */
@Service("lecturerService")
@Scope("request")
@Transactional
public class LecturerServiceImpl implements LecturerService {

    @Autowired
    private LecturerDAO lecturerDAO;

    @Override
    public void save(Lecturer lecturer) {
        lecturerDAO.save(lecturer);
    }

    @Override
    public void update(Lecturer lecturer) {
        lecturerDAO.update(lecturer);
    }

    @Override
    public void delete(Lecturer lecturer) {
        lecturerDAO.delete(lecturer);
    }

    @Override
    public Lecturer getById(Integer id) {
        return (Lecturer) lecturerDAO.getById(id);
    }

    @Override
    public List<Lecturer> getAll() {
        return lecturerDAO.getAll("Lecturer");
    }

    @Override
    public Lecturer getByEmail(String email) {
        return lecturerDAO.getByEmail(email);
    }

    @Override
    public List<UserRole> getRolesById(Integer id) {
        return lecturerDAO.getRolesById(id);
    }

}
